import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Hashtable;

public class JavaImpl {
	
	protected static Hashtable<String, String> dictionary = new Hashtable<String, String>();
	
	protected static void saveWord(String key, String value) {
		dictionary.put(key, value);
	}
	
	protected static String getWord(String key) {
		if (dictionary.containsKey(key)) {
			return dictionary.get(key);
		}
		return "eh";
	}
		
	public static void main(String[] args) {
		BufferedReader read = new BufferedReader(new InputStreamReader(System.in));
		
		String text = "-";
		while (true) {
			try {
				text=read.readLine();
			} catch (IOException e) {
			}
			if (text.equals("")) break;
			String[] parts = text.split(" ");
			saveWord(parts[1], parts[0]);
		}
		text = "-";
		while (true) {
			try {
				text=read.readLine();
			} catch (IOException e) {
			}
			if (text.equals("")) break;
			System.out.println(getWord(text));
		}
	}

}
